﻿using Basic.FormGatewaryModular.Interface;
using Basic.FormRemoteModel.Column.Model;
using Basic.FormRemoteModel.QueryColumn.Model;
using WeDonekRpc.ApiGateway.Attr;
using WeDonekRpc.Helper.Validate;
using WeDonekRpc.HttpApiGateway;
using WeDonekRpc.HttpApiGateway.Model;

namespace Basic.FormGatewaryModular.Api
{
    [ApiRouteName("/form/query/table/column/{name}")]
    internal class PhyQueryColumnApi : ApiController
    {
        private readonly IPhyQueryColumnService _Service;

        public PhyQueryColumnApi ( IPhyQueryColumnService service )
        {
            this._Service = service;
        }

        public long Add ( [NullValidate("public.param.null")] QueryColumnAdd add )
        {
            return this._Service.Add(add);
        }

        public void Delete ( [NumValidate("form.query.column.id.error", 1)] long id )
        {
            this._Service.Delete(id);
        }

        public QueryColumnDto Get ( [NumValidate("form.query.column.id.error", 1)] long id )
        {
            return this._Service.Get(id);
        }

        public bool Set ( LongParam<QueryColumnSet> set )
        {
            return this._Service.Set(set.Id, set.Value);
        }

        public bool SetSort ( QueryColSet set )
        {
            return this._Service.SetSort(set);
        }
    }
}
